# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hspec-smallcheck
pkgname=haskell-hspec-smallcheck
pkgver=0.5.3
pkgrel=20
pkgdesc="SmallCheck support for the Hspec testing framework"
url="http://hspec.github.io/"
license=('MIT')
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-call-stack' 'haskell-hspec-core' 'haskell-hunit' 'haskell-smallcheck')
makedepends=('ghc' 'haskell-base-orphans' 'haskell-hspec' 'haskell-quickcheck')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('cbf1130e11a75c6042762f94e60b51b286061b175d7d3b5b5c4c4f1477b0aa54d8bc17546b8aafe6a1601ca9a2a765bf392af80850c11cc30e68c1ae5e51146a')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
